package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.BaobeiBean;
import com.lwj.liwanjia.impl.BaobeiView;
import com.lwj.liwanjia.model.BaobeiModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/27.
 */

public class BaobeiPresenter {
    private BaobeiModel baobeiModel;
    private BaobeiView baobeiView;

    public BaobeiPresenter(BaobeiView baobeiView) {
        this.baobeiView = baobeiView;
        baobeiModel = new BaobeiModel();
    }

    public void getBaobei(String token, String str) {
        if (baobeiView != null) {
            baobeiModel.getBaobei(token, str, new Subscriber<BaobeiBean>() {
                @Override
                public void onCompleted() {
                    baobeiView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    baobeiView.showError((Exception) e);
                    baobeiView.hideProgress();
                }

                @Override
                public void onNext(BaobeiBean baobeiBean) {
                    baobeiView.getBaobei(baobeiBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    baobeiView.showProgress();
                }
            });
        }
    }
}
